<template >
  <div class="my">
    <!-- 顶部标题 -->
    <div class="my_tit">
      <span>我的</span>
    </div>
    <!-- 顶部背景图 -->
    <div class="my_head">
      <!-- 我的信息 -->
      <div class="my_info">
        <div class="info_deta">
          <!-- <img  class="date_img" src="../assets/myImg/my_three@2x.png" alt /> -->
          <img class="date_img" :src="userInfo.avatar" alt />
          <div class="date_nc">
            <span>{{userInfo.user_nickname}}</span>
            <span>{{userInfo.mobile}}</span>
          </div>
          <div class="date_bj" @click="$router.push('/perInfo')">
            <span>编辑</span>
          </div>
        </div>
      </div>
    </div>
    <ul class="my_list">
      <li class="my_item" @click="goalreadyVideo">
        <img class="my_item_img" src="../assets/myImg/my_one@2x.png" alt />
        <span>已领视频</span>
        <img class="my_item_arrow" src="../assets/myImg/arrow@2x.png" alt />
      </li>
      <li class="my_item" @click="goHarvest">
        <img class="my_item_img" src="../assets/myImg/my_two@2x.png" alt />
        <span>我的收藏</span>
        <img class="my_item_arrow" src="../assets/myImg/arrow@2x.png" alt />
      </li>
      <!-- <li class="my_item">
        <img class="my_item_img" src="../assets/myImg/my_three@2x.png" alt />
        <span>包年会员</span>
        <span style="text-align: right">已开通</span>
      </li>
      <li class="my_item">
        <img class="my_item_img" src="../assets/myImg/my_four@2x.png" alt />
        <span>支付宝绑定</span>
        <span style="text-align: right">敬请期待</span>
      </li>
      <li class="my_item">
        <img class="my_item_img" src="../assets/myImg/my_five@2x.png" alt />
        <span>好友邀请</span>
        <span style="text-align: right">敬请期待</span>
      </li>-->
      <li class="my_item" @click="goIdiomList">
        <img class="my_item_img" src="../assets/myImg/my_six@2x.png" alt />
        <span>涨粉留言</span>
        <img class="my_item_arrow" src="../assets/myImg/arrow@2x.png" alt />
      </li>
    </ul>
    <MainTabBar></MainTabBar>
  </div>
</template>

<script>
import { getUserInfos } from "../api/my";
import MainTabBar from "../components/content/MainTabBar";

export default {
  components: {
    MainTabBar,
  },
  data() {
    return {
      userInfo: "",
    };
  },
  methods: {
    // 我的收藏
    goHarvest() {
      this.$router.push({ name: "MyHarvest" });
    },
    // 已领视频
    goalreadyVideo() {
      this.$router.push({ name: "AlreadyVideo" });
    },
    // 留言列表
    goIdiomList() {
      this.$router.push({ name: "IdiomList" });
    },
    // 获取用户信息
    getUserInfos() {
      let that = this;
      getUserInfos().then((res) => {
        if (res.code == 200) {
          that.userInfo = res.data;
          // 将username存到本地
          let name = res.data.user_nickname;
          window.localStorage.setItem("username", name);
        }
      });
    },
  },
  mounted() {
    this.getUserInfos();
  },
 watch:{
 	    $route: {
 	      handler: function(val, oldVal){ 
	        if(val.name=='My'){
				  this.getUserInfos();
			}
	       
 	      },
 	      // 深度观察监听
 	      deep: true
 	    }
 }
};
</script>

<style lang="less" scoped>
.my {
  height: 100%;
  background: #f3f5f8;
}
.my_tit {
  position: absolute;
  top: 0;
  width: 100%;
  text-align: center;
  z-index: 10;
  height: 1.333333rem;
  line-height: 1.333333rem;
  font-size: 0.453333rem;
  color: #fff;
}
.my_head {
  position: relative;
  height: 3.866667rem;
  background: url(../assets/myImg/my_bg@2x.png) no-repeat;
  background-size: 100% 100%;
  .my_info {
    position: absolute;
    top: 1.466667rem;
    left: 50%;
    transform: translate(-50%);
    padding: 0.72rem 0 0.72rem 0.506667rem;
    width: 8.666667rem;
    background: #fff;
    border-radius: 0.186667rem;
    .info_deta {
      position: relative;
      display: flex;
      .date_img {
        margin-right: 0.4rem;
        height: 1.706667rem;
        width: 1.706667rem;
      }
      .date_nc {
        font-size: 0.32rem;
        color: #999;
        & span:nth-child(1) {
          display: block;
          margin: 0.266667rem 0;
          font-size: 0.426667rem;
          color: #333;
        }
      }
      .date_bj {
        position: absolute;
        top: 0.133333rem;
        right: 0;
        width: 2.026667rem;
        height: 0.8rem;
        line-height: 0.8rem;
        color: #fff;
        font-size: 0.4rem;
        background: url(../assets/myImg/BIANJI@2x.png) no-repeat;
        background-size: 100% 100%;
        span {
          position: relative;
          left: 0.853333rem;
        }
      }
    }
  }
}
.my_list {
  margin: 1.64rem 0.4rem;
  border-radius: 0.186667rem;
  background: #fff;
  .my_item {
    margin: 0 0.266667rem;
    padding: 0 0.373333rem;
    display: flex;
    height: 1.706667rem;
    line-height: 1.706667rem;
    font-size: 0.4rem;
    color: #666;
    border-bottom: 0.013333rem solid #dcdcdc;
    .my_item_img {
      margin: auto;
      margin-right: 1.066667rem;
      height: 0.64rem;
      height: 0.64rem;
    }
    span {
      flex: 1;
    }
    .my_item_arrow {
      margin: auto;
      width: 0.36rem;
      height: 0.36rem;
    }
  }
}
</style>